package <#if doc.desk.deskPackage?starts_with("cz.incad.skodaauto")>${doc.desk.deskPackage?replace("cz.incad.skodaauto","cz.incad.skoda.server")}<#else>${doc.desk.deskPackage?replace("cz.incad.core","cz.incad.skoda.server")}</#if>;

import java.util.Date;
import java.math.BigDecimal;

import org.aplikator.server.descriptor.Entity;
import org.aplikator.server.descriptor.Property;
import org.aplikator.server.descriptor.Collection;
import org.aplikator.server.descriptor.Reference;
import org.aplikator.server.descriptor.ListProvider;
import org.aplikator.server.data.BinaryData;

import static cz.incad.skoda.server.Utils.namedList;

public class ${doc.desk.deskName} extends <#if doc.desk.deskRoot != "">${doc.desk.deskRoot?replace("cz.incad.core","cz.incad.skoda.server")}<#else>Entity</#if> {
<#list doc.desk.fields.field as f>
    public <#switch f.fieldType>
    <#case "DAT">Property<Date><#break>
    <#case "STR">Property<String><#break>
    <#case "BOL">Property<Boolean><#break>
    <#case "INT">Property<Integer><#break>
    <#case "NUM">Property<BigDecimal><#break>
    <#case "TXT">Property<String><#break>
    <#case "BIN">Property<BinaryData><#break>
    <#case "TAB">Collection<${f.reference}><#break>
    <#case "REF">Reference<${f.reference}><#break>
    <#default>${f.fieldType}</#switch> ${f.fieldName};
</#list>

    public ${doc.desk.deskName}(){
<#if doc.desk.deskRoot != "">
        super("${doc.desk.deskName}");
        map("${doc.desk.deskDBName}", "${doc.desk.deskDBName}_ID");
<#else>
        super("${doc.desk.deskName}", "${doc.desk.deskDBName}", "${doc.desk.deskDBName}_ID");
</#if>
        initFields();
    }


    protected void initFields(){
<#if doc.desk.deskRoot != "">
        super.initFields();
</#if>
<#list doc.desk.fields.field as f>
         ${f.fieldName} = <#switch f.fieldType>
    <#case "DAT">date<#break>
    <#case "STR">string<#break>
    <#case "BOL">boolean<#break>
    <#case "INT">integer<#break>
    <#case "NUM">numeric<#break>
    <#case "TXT">text<#break>
    <#case "BIN">binary<#break>
    <#case "TAB">collection<#break>
    <#case "REF">reference<#break>
    <#default>${f.fieldType}</#switch>Property(<#if f.reference[0]??>"${f.reference}", </#if>"${f.fieldDBName}"<#if f.validateLength[0]??>, ${f.validateLength}</#if>)<#if f.computed[0]??>.setEditable(false)</#if><#if f.list[0]??>.setListProvider(namedList("${f.list}"))</#if>;
</#list>
    }

}
